import request from "@/axios"
//查询用户
export function search(param) {
    let url = '/api/user/search'
    return request.post(url,{param})
}

//根据上级找出用户
export function sTop() {
    let url = '/api/user/top/search'
    // if(process.env.NODE_ENV == 'wg'){
        let data = {
            type : 0
         }
        return  request.post(url,data)
    // }else {
    //     return request.post(url)
    // }

}

export function info(uid) {
    let url = '/api/user/info'
    return request.post(url,{uid})
}

export function update(tem) {
    let url = '/api/user/update'
    tem.isLoading = true
    return request.post(url,tem)
}

//列出可修改的级别
export function listLevel() {
    let url = '/api/user/level'
    return request.get(url)
}

//修改级别
export function changeLevel(toUserId,levelId) {
    let url = '/api/user/level/change'
    let data = {
        toUserId,levelId
    }
    data.isLoading = true
    return request.post(url,data)
}

//获取验证码
export function getCode(mobile) {
    let url = '/api/user/captcha'
    let params = {mobile}
    return request.get(url,{params})
}

// 查找等级与type
export function searchLevel(){
    let url = 'api/user/levels'
    return request.get(url)
}

//根据level与type查找
export function searchFromLvType(type){
    let url = `/api/user/top/search?type=${type}`
    return request.get(url)
}

//获取微信二维码
export function getQrCode() {
    let url = '/api/user/qr/code'
    return request.get(url)
}

//跳转社集优选
export function skipToSjyx(unionId,name,code,tCode,avatar,phone,topUserId,topCode){
    let url = `/api/login/wg/register`
    let data={
        unionId,name,code,tCode,avatar,phone,topUserId,topCode
    }
    // data.topUserId = 654132
    // data.phone = 1333333333
    // data.code = 'wg46456131'
    // data.unionId = '789456'
    // data.isLoading = true
    // data.topCode = '阿法发顺丰'
    // alert(data.topCode)
    // data.t_code = 'wg'
    // console.log(tCode)
    return request.request({
        url:url,
        method:'post',
        baseURL:process.env.VUE_APP_HZC_BASE_URL,
        // baseURL:'http://192.168.7.32:8080',
        data:data
    })
}
